home *** CD-ROM | disk | FTP | other *** search
/ The CICA Windows Explosion! / The CICA Windows Explosion! - Disc 2.iso / programr / appsrcs.zip / MORSETUP.ZIP / APPSYS.C < prev    next >
C/C++ Source or Header  |  1993-05-07  |  11KB  |  293 lines

  1. #define STRICT
  2. #include <windows.h>
  3. #include <windowsx.h>
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6. #include <string.h>
  7. #include "morsetup.h"
  8.  
  9. /*-------------------------------------------------------------------------*/
  10. BOOL WINAPI SystemDlgProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
  11.     {
  12.     static DLGPROC   lpfnAboutDlgProc;
  13.     HWND         hCtrl;
  14.     char         intstring[MAXDIGITS];
  15.     short         nCtrlID;
  16.     BOOL         bSigned = TRUE;
  17.  
  18.     switch(message)
  19.     {
  20.     case WM_INITDIALOG:
  21.         SetCaption(hDlg, "System Setup");
  22.         AppSystemNew = AppSystem;
  23.         CheckDlgButton(hDlg, IDD_STAYINFRONT, AppSystem.StayInFront);
  24.         CheckDlgButton(hDlg, IDD_CLOSEALL, AppSystem.CloseAll);
  25.         CheckDlgButton(hDlg, IDD_ONELAUNCH, AppSystem.OneLaunch);
  26.         CheckDlgButton(hDlg, IDD_DOUBLECLICK, AppSystemNew.DoubleClick);
  27.         CheckDlgButton(hDlg, IDD_BIGBUTTONS, AppSystem.BigButtons);
  28.         SetDlgItemInt(hDlg, IDD_LEFT, (int) AppSystemNew.Left, bSigned);
  29.         SetDlgItemInt(hDlg, IDD_TOP, (int) AppSystemNew.Top, bSigned);
  30.         SetDlgItemInt(hDlg, IDD_BUTTONS, AppSystemNew.Buttons, bSigned);
  31.         SetDlgItemInt(hDlg, IDD_ROWS, AppSystemNew.Columns, bSigned);
  32.         SetDlgItemInt(hDlg, IDD_BORDER, AppSystemNew.Border, bSigned);
  33.         return TRUE;
  34.  
  35.     case WM_VSCROLL:
  36.         hCtrl = (HWND) HIWORD(lParam);
  37.         nCtrlID = GetWindowWord(hCtrl, GWW_ID);
  38.         switch(wParam)
  39.         {
  40.         case SB_LINEDOWN:
  41.             switch(nCtrlID)
  42.             {
  43.             case IDD_SCROLLLEFT:
  44.                 GetDlgItemText(hDlg, IDD_LEFT, intstring, MAXDIGITS);
  45.                 AppSystemNew.Left = atoi(intstring);
  46.                 AppSystemNew.Left = min(MAXRES, AppSystemNew.Left);
  47.                 AppSystemNew.Left = max(-1, AppSystemNew.Left-1);
  48.                 SetDlgItemInt(hDlg, IDD_LEFT, (int) AppSystemNew.Left, bSigned);
  49.                 break;
  50.  
  51.             case IDD_SCROLLTOP:
  52.                 GetDlgItemText(hDlg, IDD_TOP, intstring, MAXDIGITS);
  53.                 AppSystemNew.Top = atoi(intstring);
  54.                 AppSystemNew.Top = min(MAXRES, AppSystemNew.Top);
  55.                 AppSystemNew.Top = max(-1, AppSystemNew.Top-1);
  56.                 SetDlgItemInt(hDlg, IDD_TOP, (int) AppSystemNew.Top, bSigned);
  57.                 break;
  58.  
  59.             case IDD_SCROLLBUTTONS:
  60.                 GetDlgItemText(hDlg, IDD_BUTTONS, intstring, MAXDIGITS);
  61.                 AppSystemNew.Buttons = atoi(intstring);
  62.                 AppSystemNew.Buttons = min(MAXAPPS, AppSystemNew.Buttons);
  63.                 AppSystemNew.Buttons = max(1, AppSystemNew.Buttons-1);
  64.                 SetDlgItemInt(hDlg, IDD_BUTTONS, AppSystemNew.Buttons, bSigned);
  65.                 if(AppSystemNew.Columns > AppSystemNew.Buttons+2) // add two systembutton's
  66.                 {
  67.                 AppSystemNew.Columns = AppSystemNew.Buttons+2;
  68.                 SetDlgItemInt(hDlg, IDD_ROWS, AppSystemNew.Columns, bSigned);
  69.                 }
  70.                 break;
  71.  
  72.             case IDD_SCROLLROWS:
  73.                 GetDlgItemText(hDlg, IDD_ROWS, intstring, MAXDIGITS);
  74.                 AppSystemNew.Columns = atoi(intstring);
  75.                 AppSystemNew.Columns = min(AppSystemNew.Buttons+2, AppSystemNew.Columns);
  76.                 AppSystemNew.Columns = max(1, AppSystemNew.Columns-1);
  77.                 SetDlgItemInt(hDlg, IDD_ROWS, AppSystemNew.Columns, bSigned);
  78.                 break;
  79.  
  80.             case IDD_SCROLLBORDER:
  81.                 GetDlgItemText(hDlg, IDD_BORDER, intstring, MAXDIGITS);
  82.                 AppSystemNew.Border = atoi(intstring);
  83.                 AppSystemNew.Border = min(MAXBORDER, AppSystemNew.Border);
  84.                 AppSystemNew.Border = max(0, AppSystemNew.Border-1);
  85.                 if(AppSystemNew.Border < 3)
  86.                 AppSystemNew.Border = 0;
  87.                 SetDlgItemInt(hDlg, IDD_BORDER, AppSystemNew.Border, bSigned);
  88.                 break;
  89.              }
  90.             break;
  91.  
  92.         case SB_LINEUP:
  93.             switch(nCtrlID)
  94.             {
  95.             case IDD_SCROLLLEFT:
  96.                 GetDlgItemText(hDlg, IDD_LEFT, intstring, MAXDIGITS);
  97.                 AppSystemNew.Left = atoi(intstring);
  98.                 AppSystemNew.Left = max(-1, AppSystemNew.Left);
  99.                 AppSystemNew.Left = min(MAXRES, AppSystemNew.Left+1);
  100.                 SetDlgItemInt(hDlg, IDD_LEFT, (int) AppSystemNew.Left, bSigned);
  101.                 break;
  102.  
  103.             case IDD_SCROLLTOP:
  104.                 GetDlgItemText(hDlg, IDD_TOP, intstring, MAXDIGITS);
  105.                 AppSystemNew.Top = atoi(intstring);
  106.                 AppSystemNew.Top = max(-1, AppSystemNew.Top);
  107.                 AppSystemNew.Top = min(MAXRES, AppSystemNew.Top+1);
  108.                 SetDlgItemInt(hDlg, IDD_TOP, (int) AppSystemNew.Top, bSigned);
  109.                 break;
  110.  
  111.             case IDD_SCROLLBUTTONS:
  112.                 GetDlgItemText(hDlg, IDD_BUTTONS, intstring, MAXDIGITS);
  113.                 AppSystemNew.Buttons = atoi(intstring);
  114.                 AppSystemNew.Buttons = max(1, AppSystemNew.Buttons);
  115.                 AppSystemNew.Buttons = min(MAXAPPS, AppSystemNew.Buttons+1);
  116.                 SetDlgItemInt(hDlg, IDD_BUTTONS, AppSystemNew.Buttons, bSigned);
  117.                 break;
  118.  
  119.             case IDD_SCROLLROWS:
  120.                 GetDlgItemText(hDlg, IDD_ROWS, intstring, MAXDIGITS);
  121.                 AppSystemNew.Columns = atoi(intstring);
  122.                 AppSystemNew.Columns = max(1, AppSystemNew.Columns);
  123.                 AppSystemNew.Columns = min(AppSystemNew.Buttons+2, AppSystemNew.Columns+1);
  124.                 SetDlgItemInt(hDlg, IDD_ROWS, AppSystemNew.Columns, bSigned);
  125.                 break;
  126.  
  127.             case IDD_SCROLLBORDER:
  128.                 GetDlgItemText(hDlg, IDD_BORDER, intstring, MAXDIGITS);
  129.                 AppSystemNew.Border = atoi(intstring);
  130.                 AppSystemNew.Border = max(0, AppSystemNew.Border);
  131.                 AppSystemNew.Border = min(MAXBORDER, AppSystemNew.Border+1);
  132.                 if(AppSystemNew.Border < 3)
  133.                 AppSystemNew.Border = 3;
  134.                 SetDlgItemInt(hDlg, IDD_BORDER, AppSystemNew.Border, bSigned);
  135.                 break;
  136.             }
  137.             break;
  138.         }
  139.         return TRUE;
  140.  
  141.     case WM_COMMAND:
  142.         switch(wParam)
  143.         {
  144.         case IDD_STAYINFRONT:
  145.             if(IsDlgButtonChecked(hDlg,IDD_STAYINFRONT))
  146.             AppSystemNew.StayInFront = 0;
  147.             else
  148.             AppSystemNew.StayInFront = 1;
  149.             CheckDlgButton(hDlg, IDD_STAYINFRONT, AppSystemNew.StayInFront);
  150.             return TRUE;
  151.  
  152.         case IDD_CLOSEALL:
  153.             if(IsDlgButtonChecked(hDlg,IDD_CLOSEALL))
  154.             AppSystemNew.CloseAll = 0;
  155.             else
  156.             AppSystemNew.CloseAll = 1;
  157.             CheckDlgButton(hDlg, IDD_CLOSEALL, AppSystemNew.CloseAll);
  158.             return TRUE;
  159.  
  160.         case IDD_ONELAUNCH:
  161.             if(IsDlgButtonChecked(hDlg,IDD_ONELAUNCH))
  162.             AppSystemNew.OneLaunch = 0;
  163.             else
  164.             AppSystemNew.OneLaunch = 1;
  165.             CheckDlgButton(hDlg, IDD_ONELAUNCH, AppSystemNew.OneLaunch);
  166.             return TRUE;
  167.  
  168.         case IDD_DOUBLECLICK:
  169.             if(IsDlgButtonChecked(hDlg,IDD_DOUBLECLICK))
  170.             AppSystemNew.DoubleClick = 0;
  171.             else
  172.             AppSystemNew.DoubleClick = 1;
  173.             CheckDlgButton(hDlg, IDD_DOUBLECLICK, AppSystemNew.DoubleClick);
  174.             return TRUE;
  175.  
  176.         case IDD_BIGBUTTONS:
  177.             if(IsDlgButtonChecked(hDlg,IDD_BIGBUTTONS))
  178.             AppSystemNew.BigButtons = 0;
  179.             else
  180.             AppSystemNew.BigButtons = 1;
  181.             CheckDlgButton(hDlg, IDD_BIGBUTTONS, AppSystemNew.BigButtons);
  182.             return TRUE;
  183.  
  184.         case IDD_LEFT:
  185.             if(HIWORD(lParam) == EN_KILLFOCUS)
  186.             {
  187.             GetDlgItemText(hDlg, IDD_LEFT, intstring, MAXDIGITS);
  188.             AppSystemNew.Left = atoi(intstring);
  189.             AppSystemNew.Left = min(MAXRES, AppSystemNew.Left);
  190.             AppSystemNew.Left = max(-1, AppSystemNew.Left);
  191.             SetDlgItemInt(hDlg, IDD_LEFT, (int) AppSystemNew.Left, bSigned);
  192.             }
  193.             return TRUE;
  194.  
  195.         case IDD_TOP:
  196.             if(HIWORD(lParam) == EN_KILLFOCUS)
  197.             {
  198.             GetDlgItemText(hDlg, IDD_TOP, intstring, MAXDIGITS);
  199.             AppSystemNew.Top = atoi(intstring);
  200.             AppSystemNew.Top = min(MAXRES, AppSystemNew.Top);
  201.             AppSystemNew.Top = max(-1, AppSystemNew.Top);
  202.             SetDlgItemInt(hDlg, IDD_TOP, (int) AppSystemNew.Top, bSigned);
  203.             }
  204.             return TRUE;
  205.  
  206.         case IDD_BUTTONS:
  207.             if(HIWORD(lParam) == EN_KILLFOCUS)
  208.             {
  209.             GetDlgItemText(hDlg, IDD_BUTTONS, intstring, MAXDIGITS);
  210.             AppSystemNew.Buttons = atoi(intstring);
  211.             AppSystemNew.Buttons = min(MAXAPPS, AppSystemNew.Buttons);
  212.             AppSystemNew.Buttons = max(1, AppSystemNew.Buttons);
  213.             SetDlgItemInt(hDlg, IDD_BUTTONS, AppSystemNew.Buttons, bSigned);
  214.             if(AppSystemNew.Columns > AppSystemNew.Buttons)
  215.                 {
  216.                 AppSystemNew.Columns = AppSystemNew.Buttons;
  217.                 SetDlgItemInt(hDlg, IDD_ROWS, AppSystemNew.Columns, bSigned);
  218.                 }
  219.             }
  220.             return TRUE;
  221.  
  222.         case IDD_ROWS:
  223.             if(HIWORD(lParam) == EN_KILLFOCUS)
  224.             {
  225.             GetDlgItemText(hDlg, IDD_ROWS, intstring, MAXDIGITS);
  226.             AppSystemNew.Columns = atoi(intstring);
  227.             AppSystemNew.Columns = min(AppSystem.Buttons, AppSystemNew.Columns);
  228.             AppSystemNew.Columns = max(1, AppSystemNew.Columns);
  229.             SetDlgItemInt(hDlg, IDD_ROWS, AppSystemNew.Columns, bSigned);
  230.             }
  231.             return TRUE;
  232.  
  233.         case IDD_BORDER:
  234.             if(HIWORD(lParam) == EN_KILLFOCUS)
  235.             {
  236.             GetDlgItemText(hDlg, IDD_BORDER, intstring, MAXDIGITS);
  237.             AppSystemNew.Border = atoi(intstring);
  238.             AppSystemNew.Border = min(MAXBORDER, AppSystemNew.Border);
  239.             AppSystemNew.Columns = max(0, AppSystemNew.Border);
  240.             if(AppSystemNew.Border < 3)
  241.                 AppSystemNew.Border = 0;
  242.             SetDlgItemInt(hDlg, IDD_BORDER, AppSystemNew.Border, bSigned);
  243.             }
  244.             return TRUE;
  245.  
  246.         case IDD_DEFAULT:
  247.             AppSystemNew.Left = (LEFT_DEFAULT);
  248.             AppSystemNew.Top = (TOP_DEFAULT);
  249.             AppSystemNew.Columns = (COLUMNS_DEFAULT);
  250.             AppSystemNew.Buttons = (BUTTONS_DEFAULT);
  251.             AppSystemNew.OneLaunch = (ONELAUNCH_DEFAULT);
  252.             AppSystemNew.CloseAll = (CLOSEALL_DEFAULT);
  253.             AppSystemNew.StayInFront = (STAYINFRONT_DEFAULT);
  254.             AppSystemNew.DoubleClick = (DOUBLECLICK_DEFAULT);
  255.             AppSystemNew.BigButtons = (BIGBUTTONS_DEFAULT);
  256.             CheckDlgButton(hDlg, IDD_STAYINFRONT, AppSystemNew.StayInFront);
  257.             CheckDlgButton(hDlg, IDD_CLOSEALL, AppSystemNew.CloseAll);
  258.             CheckDlgButton(hDlg, IDD_ONELAUNCH, AppSystemNew.OneLaunch);
  259.             CheckDlgButton(hDlg, IDD_DOUBLECLICK, AppSystemNew.DoubleClick);
  260.             SetDlgItemText(hDlg, IDD_LEFT, (LPSTR) LEFT_DEFAULT);
  261.             SetDlgItemText(hDlg, IDD_TOP, (LPSTR) TOP_DEFAULT);
  262.             SetDlgItemText(hDlg, IDD_BUTTONS, (LPSTR) BUTTONS_DEFAULT);
  263.             SetDlgItemText(hDlg, IDD_ROWS, (LPSTR) COLUMNS_DEFAULT);
  264.             SetDlgItemText(hDlg, IDD_BORDER, (LPSTR) BORDER_DEFAULT);
  265.             return TRUE;
  266.  
  267.         case IDD_ABOUT:
  268.             lpfnAboutDlgProc = (DLGPROC) MakeProcInstance(AboutDlgProc, hInst);
  269.             DialogBox(hInst, "AboutDlg", hWnd, lpfnAboutDlgProc);
  270.             FreeProcInstance((FARPROC) lpfnAboutDlgProc);
  271.             break;
  272.  
  273.         case IDD_HELP:
  274.             WinHelp(hWnd, "AppMore.hlp",HELP_CONTENTS, 0L);
  275.             return TRUE;
  276.  
  277.         case IDOK:
  278.             AppSystem = AppSystemNew;
  279.             bSave = TRUE;
  280.             EndDialog(hDlg, 0);
  281.             InvalidateRect(hWnd, NULL, 0);
  282.             return TRUE;
  283.  
  284.         case IDCANCEL:
  285.             EndDialog(hDlg, 0);
  286.             InvalidateRect(hWnd, NULL, 0);
  287.             return TRUE;
  288.         }
  289.         break;
  290.     }
  291.     return FALSE;
  292.     }
  293.